<script setup>
import { Refresh } from '@element-plus/icons-vue'
import { getOneQuote } from '@/apis/quote'
import { onMounted, ref } from 'vue'

const quote = ref(null)

async function getQuote() {
  const res = await getOneQuote()
  quote.value = res.data
}

onMounted(() => {
  getQuote()
})
</script>

<template>
  <div class="daily-advice">
    <h1 class="title">每日名言</h1>
    <div class="content">
      <i>"{{ quote?.quote }}"</i>
      <p>—— {{ quote?.author }}</p>
    </div>
    <el-button type="primary" @click="getQuote()">
      <el-icon class="el-icon--left"><Refresh /></el-icon>换一句
    </el-button>
  </div>
</template>

<style scoped lang="scss">
.daily-advice {
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 10px;
  border-radius: 10px;
  background-color: white;

  .title {
    font-family: Roboto;
    font-size: 16px;
    font-weight: 700;
    line-height: 24px;
    text-align: center;
    letter-spacing: normal;
    color: #000000;
  }

  .content {
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 10px;
    min-height: 100px;
    background-color: #f2f3f5;
    border-radius: 8px;

    i {
      font-family: Source Han Sans;
      font-size: 14px;
      font-weight: normal;
      line-height: 24px;
      text-align: center;
      letter-spacing: normal;
      color: #4b5563;
    }

    p {
      align-self: flex-end;
      font-family: Roboto;
      font-size: 12px;
      font-weight: bold;
      line-height: 20px;
      text-align: center;
      letter-spacing: normal;
      color: #6b7280;
    }
  }
}
</style>
